package com.qf.controller;

import com.qf.pojo.RolePojo;
import com.qf.service.RoleService;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/role")
public class RoleController {

    @Autowired
    RoleService roleService;


    @PostMapping("/add")
    @ResponseBody
    public ResultMsg add(@RequestBody RolePojo rolePojo){
        return roleService.add(rolePojo);
    }

    @GetMapping("/findAll")
    public ResultMsg findAll(String keyword){
        return roleService.findAll(keyword);
    }

    @GetMapping("/delById/{roleId}")
    public ResultMsg delById(@PathVariable Integer roleId){
        return roleService.delById(roleId);
    }

    @PostMapping("/update")
    @ResponseBody
    public ResultMsg update(@RequestBody RolePojo rolePojo){
        return roleService.update(rolePojo);
    }
}
